<?php


abstract class BaseAyudantia extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $cp_ayudantia;


	
	protected $cf_beneficio_estudiante;


	
	protected $numero_horas;


	
	protected $departamento;


	
	protected $jefe;


	
	protected $estatus;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getCpAyudantia()
	{

		return $this->cp_ayudantia;
	}

	
	public function getCfBeneficioEstudiante()
	{

		return $this->cf_beneficio_estudiante;
	}

	
	public function getNumeroHoras()
	{

		return $this->numero_horas;
	}

	
	public function getDepartamento()
	{

		return $this->departamento;
	}

	
	public function getJefe()
	{

		return $this->jefe;
	}

	
	public function getEstatus()
	{

		return $this->estatus;
	}

	
	public function setCpAyudantia($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cp_ayudantia !== $v) {
			$this->cp_ayudantia = $v;
			$this->modifiedColumns[] = AyudantiaPeer::CP_AYUDANTIA;
		}

	} 
	
	public function setCfBeneficioEstudiante($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_beneficio_estudiante !== $v) {
			$this->cf_beneficio_estudiante = $v;
			$this->modifiedColumns[] = AyudantiaPeer::CF_BENEFICIO_ESTUDIANTE;
		}

	} 
	
	public function setNumeroHoras($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->numero_horas !== $v) {
			$this->numero_horas = $v;
			$this->modifiedColumns[] = AyudantiaPeer::NUMERO_HORAS;
		}

	} 
	
	public function setDepartamento($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->departamento !== $v) {
			$this->departamento = $v;
			$this->modifiedColumns[] = AyudantiaPeer::DEPARTAMENTO;
		}

	} 
	
	public function setJefe($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->jefe !== $v) {
			$this->jefe = $v;
			$this->modifiedColumns[] = AyudantiaPeer::JEFE;
		}

	} 
	
	public function setEstatus($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->estatus !== $v) {
			$this->estatus = $v;
			$this->modifiedColumns[] = AyudantiaPeer::ESTATUS;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->cp_ayudantia = $rs->getString($startcol + 0);

			$this->cf_beneficio_estudiante = $rs->getString($startcol + 1);

			$this->numero_horas = $rs->getInt($startcol + 2);

			$this->departamento = $rs->getString($startcol + 3);

			$this->jefe = $rs->getString($startcol + 4);

			$this->estatus = $rs->getString($startcol + 5);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 6; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Ayudantia object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(AyudantiaPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			AyudantiaPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(AyudantiaPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = AyudantiaPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setCpAyudantia($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += AyudantiaPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = AyudantiaPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = AyudantiaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getCpAyudantia();
				break;
			case 1:
				return $this->getCfBeneficioEstudiante();
				break;
			case 2:
				return $this->getNumeroHoras();
				break;
			case 3:
				return $this->getDepartamento();
				break;
			case 4:
				return $this->getJefe();
				break;
			case 5:
				return $this->getEstatus();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = AyudantiaPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCpAyudantia(),
			$keys[1] => $this->getCfBeneficioEstudiante(),
			$keys[2] => $this->getNumeroHoras(),
			$keys[3] => $this->getDepartamento(),
			$keys[4] => $this->getJefe(),
			$keys[5] => $this->getEstatus(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = AyudantiaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setCpAyudantia($value);
				break;
			case 1:
				$this->setCfBeneficioEstudiante($value);
				break;
			case 2:
				$this->setNumeroHoras($value);
				break;
			case 3:
				$this->setDepartamento($value);
				break;
			case 4:
				$this->setJefe($value);
				break;
			case 5:
				$this->setEstatus($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = AyudantiaPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setCpAyudantia($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCfBeneficioEstudiante($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setNumeroHoras($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDepartamento($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setJefe($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setEstatus($arr[$keys[5]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(AyudantiaPeer::DATABASE_NAME);

		if ($this->isColumnModified(AyudantiaPeer::CP_AYUDANTIA)) $criteria->add(AyudantiaPeer::CP_AYUDANTIA, $this->cp_ayudantia);
		if ($this->isColumnModified(AyudantiaPeer::CF_BENEFICIO_ESTUDIANTE)) $criteria->add(AyudantiaPeer::CF_BENEFICIO_ESTUDIANTE, $this->cf_beneficio_estudiante);
		if ($this->isColumnModified(AyudantiaPeer::NUMERO_HORAS)) $criteria->add(AyudantiaPeer::NUMERO_HORAS, $this->numero_horas);
		if ($this->isColumnModified(AyudantiaPeer::DEPARTAMENTO)) $criteria->add(AyudantiaPeer::DEPARTAMENTO, $this->departamento);
		if ($this->isColumnModified(AyudantiaPeer::JEFE)) $criteria->add(AyudantiaPeer::JEFE, $this->jefe);
		if ($this->isColumnModified(AyudantiaPeer::ESTATUS)) $criteria->add(AyudantiaPeer::ESTATUS, $this->estatus);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(AyudantiaPeer::DATABASE_NAME);

		$criteria->add(AyudantiaPeer::CP_AYUDANTIA, $this->cp_ayudantia);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getCpAyudantia();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setCpAyudantia($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setCfBeneficioEstudiante($this->cf_beneficio_estudiante);

		$copyObj->setNumeroHoras($this->numero_horas);

		$copyObj->setDepartamento($this->departamento);

		$copyObj->setJefe($this->jefe);

		$copyObj->setEstatus($this->estatus);


		$copyObj->setNew(true);

		$copyObj->setCpAyudantia(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new AyudantiaPeer();
		}
		return self::$peer;
	}

} 